home *** CD-ROM | disk | FTP | other *** search
/ Night Owl - The Best of BBS / Night Owl The Best of BBS (NOP-BBS) (Night Owl Publisher) (1994).iso / 014a / ezbbs215.lha / Source / eazy2news.c < prev    next >
C/C++ Source or Header  |  1994-02-06  |  2KB  |  103 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #include <time.h>
  5. #include <proto/dos.h>
  6. #include <proto/exec.h>
  7.  
  8.  
  9.  
  10. #define VERSION "1.7"
  11. static char *version = "\0$VER: eazy2news "VERSION" ("__AMIGADATE__")";
  12. static char *day_names[] = {"Sun","Mon","Tue","Wed","Thu","Fri","Sat"};
  13. static char *month_names[] = {"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"};
  14.  
  15.  
  16.  
  17. void space2under(char *s)
  18. {
  19.   while (s && *s) {
  20.     if (*s==' ')
  21.       *s = '_';
  22.     s++;
  23.   }
  24. }
  25.  
  26.  
  27.  
  28. int main(int argc, char *argv[])
  29. {
  30.   if (argc==7) {
  31.     char tmp[80];
  32.     FILE *fp;
  33.  
  34.     sprintf(tmp,"%s%ld","MB_TMP:Eazy2News.tmp",(long)FindTask(NULL));
  35.  
  36.     if (fp=fopen(tmp,"w")) {
  37.       register int c=0,last=0;
  38.       time_t t;
  39.       struct tm *ut;
  40.       char uname[16];
  41.       char *sname = argv[3];
  42.       char *ngrps = argv[1];
  43.       char *excld = argv[2];
  44.       char *realn = argv[5];
  45.       char *sbjct = argv[6];
  46.       char exec[256];
  47.  
  48.       time(&t);
  49.       ut = gmtime(&t);
  50.  
  51.       strcpy(uname,argv[4]);
  52.       space2under(uname);
  53.  
  54.       fprintf(fp,"Path: news\n");
  55.       fprintf(fp,"Newsgroups: %s\n",ngrps);
  56.       fprintf(fp,"From: %s@%s (%s)\n",uname,sname,realn);
  57.       fprintf(fp,"Sender: eazybbs@%s\n",sname);
  58.       fprintf(fp,"Subject: %s\n",sbjct);
  59.       fprintf(fp,"Message-ID: <%ld.eazybbs@%s>\n",t,sname);
  60.       fprintf(fp,"Date: %s, %.2d %s %d %.2d:%.2d:%.2d %sGMT\n",
  61.                 day_names[ut->tm_wday],
  62.                 ut->tm_mday,month_names[ut->tm_mon],ut->tm_year+1900,
  63.                 ut->tm_hour,ut->tm_min,ut->tm_sec,ut->tm_isdst?"DST":"");
  64.       fprintf(fp,"MIME-Version: 1.0\n");
  65.       fprintf(fp,"Content-Type: text/plain; charset=ISO-8859-1\n");
  66.       fprintf(fp,"Content-Transfer-Encoding: 8bit\n");
  67.       fprintf(fp,"\n");
  68.  
  69.       while ((c=getchar())!=EOF) {
  70.         if (last=='\\') {
  71.           switch (c) {
  72.           case '\\': fputc(c,fp);
  73.                      break;
  74.           default  : break;
  75.           }
  76.           last = 0;
  77.         }
  78.         else if (c=='\\') {
  79.           last = c;
  80.         }
  81.         else {
  82.           fputc(c,fp);
  83.           last = c;
  84.         }
  85.       }
  86.       fprintf(fp,"\n");
  87.  
  88.       fclose(fp);
  89.  
  90.       sprintf(exec,"relaynews -x %s -r -s <%s",excld,tmp);
  91.       System(exec,NULL);
  92.       DeleteFile(tmp);
  93.     }
  94.   }
  95.   else {
  96.     fprintf(stderr,"\033[1;33mEazyBBS\033[0m ⌐ 1988-1994 Andreas M. Kirchwitz\n"
  97.                    "Usage: eazy2news \033[3m<newsgroup> <excl-cmd> <site> <user> <real> <subject> \033[0m <text\n");
  98.   }
  99.  
  100.   exit(0);
  101. }
  102.  
  103.